﻿using Autofac;
using System;
using System.Reflection;

namespace Solution.Application.Injection
{
    public static class AssemblyInjection
    {
        public static void AddAssembly(this ContainerBuilder builder, Type baseType, string assemblyString)
        {
            var assemblys = Assembly.Load(assemblyString);
            builder.RegisterAssemblyTypes(assemblys).Where(p => baseType.IsAssignableFrom(p) && p != baseType).AsImplementedInterfaces().InstancePerLifetimeScope();
        }
    }
}